rm(list = ls())

library(checkpoint)
library(texreg)

checkpoint("2018-06-15", project = "your_own_wd", checkpointLocation = "cp_location")

resultspath <- "resultspath" #from models_in_paper.R
wd <- "your_own_wd"

load(file=paste0(resultspath, 'm_6.RData'))
load(file=paste0(resultspath, 'm_7.RData'))

#####################################################
# year categorical X region X distance from the gov #
#####################################################

htmlreg(l=list(m.6[[2]]),
        caption = "",  
        digits=2, file=paste0(wd, "table5_app.html"),
        single.row=TRUE,
        custom.gof.names = c(NA,
                             NA,
                             NA,
                             NA,
                             "Country*Years",
                             "Countries",
                             "Var Country*Years: Intercept",
                             "Var Country*Years: Extreme Left",
                             "Var Country*Years: Center",
                             "Var Country*Years: Right",
                             "Var Country*Years: Extreme Right",
                             "Cov Country*Years: Intercept, Ext Left",
                             "Cov Country*Years: Intercept, Center",
                             "Cov Country*Years: Intercept, Right",
                             "Cov Country*Years: Intercept, Ext Right",
                             "Cov Country*Years: Ext Left, Center",
                             "Cov Country*Years: Ext Left, Right",
                             "Cov Country*Years: Ext Left, Ext Right",
                             "Cov Country*Years: Center, Right",
                             "Cov Country*Years: Center, Ext Right",
                             "Cov Country*Years: Right, Ext Right",
                             "Var Country: Intercept"),
        custom.coef.map = list("(Intercept)"="Intercept",
                               rideol1="Extreme left (base: left)",
                               rideol3="Center",
                               rideol4="Right",
                               rideol5="Extreme right",
                               gov_dist="Distance from the gov.",
                               union1 = "Union member (dichot.)",
                               prtdgcl_num = "Party ID (cont.)",
                               gincdif = "Income diff. (cont.)",
                               freehms = "Gay rights (cont.)",
                               conformity = "Conformity (cont.)",
                               universalism = "Universalism (cont.)",
                               security = "Security (cont.)",
                               gender1="Male",
                               agea="Age (cont.)",
                               eduyrs="Years of education (cont.)",
                               domicil2="Suburbs (base: big city)",
                               domicil3="Small City",
                               domicil4="Village",
                               domicil5="Countryside",
                               unemployed1="Unemployed",
                               transition="Transition protest level",
                               gov_genlr="Gov. L-R",
                               gdp_wb_ppp="GDP (ppp, 2011 US$)",
                               wb_vae="Voice & Accountability",
                               "year2004"="2004 (base: 2002)",
                               "year2006"="2006",
                               "year2008"="2008",
                               "year2010"="2010",
                               "year2012"="2012",
                               "year2014"="2014",
                               "year2016"="2016",
                               region2="Southern Europe (base: Northwestern)",
                               region3="Eastern Europe",
                               "region2:gov_dist"="Gov. dist*SE",
                               "region3:gov_dist"="Gov. dist*EE",
                               "region2:year2004"="SE*2004",
                               "region2:year2006"="SE*2006",
                               "region2:year2008"="SE*2008",
                               "region2:year2010"="SE*2010",
                               "region2:year2012"="SE*2012",
                               "region2:year2014"="SE*2014",
                               "region2:year2016"="SE*2016",
                               "region3:year2004"="EE*2004",
                               "region3:year2006"="EE*2006",
                               "region3:year2008"="EE*2008",
                               "region3:year2010"="EE*2010",
                               "region3:year2012"="EE*2012",
                               "region3:year2014"="EE*2014",
                               "region3:year2016"="EE*2016",
                               "gov_dist:year2004"="Gov. Dist.*2004",
                               "gov_dist:year2006"="Gov. Dist.*2006",
                               "gov_dist:year2008"="Gov. Dist.*2008",
                               "gov_dist:year2010"="Gov. Dist.*2010",
                               "gov_dist:year2012"="Gov. Dist.*2012",
                               "gov_dist:year2014"="Gov. Dist.*2014",
                               "gov_dist:year2016"="Gov. Dist.*2016",
                               "region2:gov_dist:year2004"="Gov. Dist.*2004*SE",
                               "region2:gov_dist:year2006"="Gov. Dist.*2006*SE",
                               "region2:gov_dist:year2008"="Gov. Dist.*2008*SE",
                               "region2:gov_dist:year2010"="Gov. Dist.*2010*SE",
                               "region2:gov_dist:year2012"="Gov. Dist.*2012*SE",
                               "region2:gov_dist:year2014"="Gov. Dist.*2014*SE",
                               "region2:gov_dist:year2016"="Gov. Dist.*2016*SE",
                               "region3:gov_dist:year2004"="Gov. Dist.*2004*EE",
                               "region3:gov_dist:year2006"="Gov. Dist.*2006*EE",
                               "region3:gov_dist:year2008"="Gov. Dist.*2008*EE",
                               "region3:gov_dist:year2010"="Gov. Dist.*2010*EE",
                               "region3:gov_dist:year2012"="Gov. Dist.*2012*EE",
                               "region3:gov_dist:year2014"="Gov. Dist.*2014*EE",
                               "region3:gov_dist:year2016"="Gov. Dist.*2016*EE"))



#################################################
# year categorical X region X personal ideology #
#################################################

htmlreg(l=list(m.7[[1]]),
        digits=2, file=paste0(wd, "year_dummies_app.html"),
        single.row=TRUE,
        caption="",
        custom.gof.names = c(NA,
                             NA,
                             NA,
                             NA,
                             "Cntry*Yrs",
                             "Countries",
                             "Var Cntry*Yrs: Intercept",
                             "Var Cntry*Yrs: Extreme Left",
                             "Var Cntry*Yrs: Center",
                             "Var Cntry*Yrs: Right",
                             "Var Cntry*Yrs: Extreme Right",
                             "Cov Cntry*Yrs: Intercept, Ext Left",
                             "Cov Cntry*Yrs: Intercept, Center",
                             "Cov Cntry*Yrs: Intercept, Right",
                             "Cov Cntry*Yrs: Intercept, Ext Right",
                             "Cov Cntry*Yrs: Ext Left, Center",
                             "Cov Cntry*Yrs: Ext Left, Right",
                             "Cov Cntry*Yrs: Ext Left, Ext Right",
                             "Cov Cntry*Yrs: Center, Right",
                             "Cov Cntry*Yrs: Center, Ext Right",
                             "Cov Cntry*Yrs: Right, Ext Right",
                             "Var Country: Intercept"),
        custom.coef.map = list("(Intercept)"="Intercept",
                               rideol1="Extreme left (base: left)",
                               rideol3="Center",
                               rideol4="Right",
                               rideol5="Extreme right",
                               union1 = "Union member (dichot.)",
                               prtdgcl_num = "Party ID (cont.)",
                               gender1="Male",
                               agea="Age (cont.)",
                               eduyrs="Years of education (cont.)",
                               domicil2="Suburbs (base: big city)",
                               domicil3="Small City",
                               domicil4="Village",
                               domicil5="Countryside",
                               unemployed1="Unemployed",
                               gov_genlr="Gov. L-R",
                               gdp_wb_ppp="GDP (ppp, 2011 US$)",
                               wb_vae="Voice & Accountability",
                               region2="Southern Europe (base: Northwestern)",
                               region3="Eastern Europe",
                               year2004=2004,
                               year2006=2006,
                               year2008=2008,
                               year2010=2010,
                               year2012=2012,
                               year2014=2014,
                               year2016=2016,
                               "region2:rideol1"="Ext Left*SE",
                               "region2:rideol2"="Left*SE",
                               "region2:rideol3"="Center*SE",
                               "region2:rideol4"="Right*SE",
                               "region2:rideol5"="Ext Right*SE",
                               "region3:rideol1"="Ext Left*EE",
                               "region3:rideol2"="Left*EE",
                               "region3:rideol3"="Center*EE",
                               "region3:rideol4"="Right*EE",
                               "region3:rideol5"="Ext Right*EE",
                               "region2:year2004"="SE*2004",
                               "region3:year2004"="EE*2004",
                               "region2:year2006"="SE*2006",
                               "region3:year2006"="EE*2006",
                               "region2:year2008"="SE*2008",
                               "region3:year2008"="EE*2008",
                               "region2:year2010"="SE*2010",
                               "region3:year2010"="EE*2010",
                               "region2:year2012"="SE*2012",
                               "region3:year2012"="EE*2012",
                               "region2:year2014"="SE*2014",
                               "region3:year2014"="EE*2014",
                               "region2:year2016"="SE*2016",
                               "region3:year2016"="EE*2016",
                               "rideol1:year2004"="Rad Left*2004",
                               "rideol3:year2004"="Center*2004",
                               "rideol4:year2004"="Right*2004",
                               "rideol5:year2004"="Ext Right*2004",
                               "rideol1:year2006"="Rad Left*2006",
                               "rideol3:year2006"="Center*2006",
                               "rideol4:year2006"="Right*2006",
                               "rideol5:year2006"="Ext Right*2006",
                               "rideol1:year2008"="Rad Left*2008",
                               "rideol3:year2008"="Center*2008",
                               "rideol4:year2008"="Right*2008",
                               "rideol5:year2008"="Ext Right*2008",
                               "rideol1:year2010"="Rad Left*2010",
                               "rideol3:year2010"="Center*2010",
                               "rideol4:year2010"="Right*2010",
                               "rideol5:year2010"="Ext Right*2010",
                               "rideol1:year2012"="Rad Left*2012",
                               "rideol3:year2012"="Center*2012",
                               "rideol4:year2012"="Right*2012",
                               "rideol5:year2012"="Ext Right*2012",
                               "rideol1:year2014"="Rad Left*2014",
                               "rideol3:year2014"="Center*2014",
                               "rideol4:year2014"="Right*2014",
                               "rideol5:year2014"="Ext Right*2014",
                               "rideol1:year2016"="Rad Left*2016",
                               "rideol3:year2016"="Center*2016",
                               "rideol4:year2016"="Right*2016",
                               "rideol5:year2016"="Ext Right*2016",
                               "region2:rideol1:year2004"="SE*Rad Left*2004",
                               "region3:rideol1:year2004"="EE*Rad Left*2004",
                               "region2:rideol3:year2004"="SE*Center*2004",
                               "region3:rideol3:year2004"="EE*Center*2004",
                               "region2:rideol4:year2004"="SE*Right*2004",
                               "region3:rideol4:year2004"="EE*Right*2004",
                               "region2:rideol5:year2004"="SE*Ext Right*2004",
                               "region3:rideol5:year2004"="EE*Ext Right*2004",
                               "region2:rideol1:year2006"="SE*Rad Left*2006",
                               "region3:rideol1:year2006"="EE*Rad Left*2006",
                               "region2:rideol3:year2006"="SE*Center*2006",
                               "region3:rideol3:year2006"="EE*Center*2006",
                               "region2:rideol4:year2006"="SE*Right*2006",
                               "region3:rideol4:year2006"="EE*Right*2006",
                               "region2:rideol5:year2006"="SE*Ext Right*2006",
                               "region3:rideol5:year2006"="EE*Ext Right*2006",
                               "region2:rideol1:year2008"="SE*Rad Left*2008",
                               "region3:rideol1:year2008"="EE*Rad Left*2008",
                               "region2:rideol3:year2008"="SE*Center*2008",
                               "region3:rideol3:year2008"="EE*Center*2008",
                               "region2:rideol4:year2008"="SE*Right*2008",
                               "region3:rideol4:year2008"="EE*Right*2008",
                               "region2:rideol5:year2008"="SE*Ext Right*2008",
                               "region3:rideol5:year2008"="EE*Ext Right*2008",
                               "region2:rideol1:year2010"="SE*Rad Left*2010",
                               "region3:rideol1:year2010"="EE*Rad Left*2010",
                               "region2:rideol3:year2010"="SE*Center*2010",
                               "region3:rideol3:year2010"="EE*Center*2010",
                               "region2:rideol4:year2010"="SE*Right*2010",
                               "region3:rideol4:year2010"="EE*Right*2010",
                               "region2:rideol5:year2010"="SE*Ext Right*2010",
                               "region3:rideol5:year2010"="EE*Ext Right*2010",
                               "region2:rideol1:year2012"="SE*Rad Left*2012",
                               "region3:rideol1:year2012"="EE*Rad Left*2012",
                               "region2:rideol3:year2012"="SE*Center*2012",
                               "region3:rideol3:year2012"="EE*Center*2012",
                               "region2:rideol4:year2012"="SE*Right*2012",
                               "region3:rideol4:year2012"="EE*Right*2012",
                               "region2:rideol5:year2012"="SE*Ext Right*2012",
                               "region3:rideol5:year2012"="EE*Ext Right*2012",
                               "region2:rideol1:year2014"="SE*Rad Left*2014",
                               "region3:rideol1:year2014"="EE*Rad Left*2014",
                               "region2:rideol3:year2014"="SE*Center*2014",
                               "region3:rideol3:year2014"="EE*Center*2014",
                               "region2:rideol4:year2014"="SE*Right*2014",
                               "region3:rideol4:year2014"="EE*Right*2014",
                               "region2:rideol5:year2014"="SE*Ext Right*2014",
                               "region3:rideol5:year2014"="EE*Ext Right*2014",
                               "region2:rideol1:year2016"="SE*Rad Left*2016",
                               "region3:rideol1:year2016"="EE*Rad Left*2016",
                               "region2:rideol3:year2016"="SE*Center*2016",
                               "region3:rideol3:year2016"="EE*Center*2016",
                               "region2:rideol4:year2016"="SE*Right*2016",
                               "region3:rideol4:year2016"="EE*Right*2016",
                               "region2:rideol5:year2016"="SE*Ext Right*2016",
                               "region3:rideol5:year2016"="EE*Ext Right*2016"))



